<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<%@ taglib prefix="s" uri="/struts-tags" %>
<html>
<head>
    <title>Add RatePlan</title>
    <link type="text/css" href="${contextPath}/static/style/global.css" rel="stylesheet"/>
    <script type="text/javascript" src="${contextPath}/static/script/jquery/jquery-1.4.2.js"></script>
    <script type="text/javascript" src="${contextPath}/static/script/jquery/jquery.validate.js"></script>
    <script type="text/javascript" language="JavaScript">
        function create_rate_plan() {
            $("input:checkbox").eq(0).val($("input:checkbox").eq(0).attr("checked"));
            $("#freeMeal_ratePlan").val($("#rate_plan_code").val());
            $("#mainForm").attr("action", "./add.dhtml");
            $("#mainForm").submit();
        }

        $(function() {
            $("#mainForm").validate();
        });
        function clean_error(obj) {
            obj.parent().children("span:eq(0)").remove();
        }
    </script>
</head>
<body>
<div class="main">
    <form id="mainForm">
        <fieldset>
            <legend>
                <span class="title">Rate Plan Information</span>
            </legend>
            <table class="table_list">
                <tr>
                    <td class="key">Code:</td>
                    <td class="value">
                        <input type="text" id="rate_plan_code" class="required" value="${ratePlan.code}"
                               name="ratePlan.code" onblur="clean_error($(this));"/>
                        <s:if test="#request.error_desc !=null">
                            <span style="color:red;">${error_desc}</span>
                        </s:if>
                    </td>
                </tr>
                <tr>
                    <td class="key">Name:</td>
                    <td class="value"><input type="text" class="required" name="ratePlan.name"/></td>
                </tr>
                <tr>
                    <td class="key">Description:</td>
                    <td class="value"><textarea name="ratePlan.description" cols="80"></textarea></td>
                </tr>
                <tr>
                    <td class="key">FreeMealType:</td>
                    <td class="value">
                        <select class="select" name="ratePlan.freeMeal.type">
                            <s:iterator value="@com.derbysoft.remote.dswitch.hotel.constants.FreeMealType@values()"
                                        id="freeMealType">
                                <option value="${freeMealType}">${freeMealType}</option>
                            </s:iterator>
                        </select>
                    </td>
                </tr>
                <tr>
                    <input type="hidden" id="freeMeal_ratePlan" name="ratePlan.freeMeal.ratePlan"/>
                    <td class="key">FreeMealUnit:</td>
                    <td class="value">
                        <select class="select" name="ratePlan.freeMeal.unit">
                            <s:iterator value="@com.derbysoft.remote.dswitch.hotel.constants.FreeMealUnit@values()"
                                        id="freeMealUnit">
                                <option value="${freeMealUnit}">${freeMealUnit}</option>
                            </s:iterator>
                        </select>
                    </td>
                </tr>
                <tr>
                    <td class="key">FreeMealQuantity:</td>
                    <td class="value"><input type="text" class="longText" name="ratePlan.freeMeal.quantity"/></td>
                </tr>
                <tr>
                    <td class="key">FreeMealDescription:</td>
                    <td class="value"><input type="text" class="longText"
                                             name="ratePlan.freeMeal.description"/></td>
                </tr>
                <tr>
                    <td class="key">Guarantee:</td>
                    <td class="value">
                        <input type="checkbox" name="ratePlan.needGuarantee"/>NeedGuarantee
                    </td>
                </tr>
                <tr>
                    <td class="key">RateType:</td>
                    <td class="value">
                        <select class="select" name="ratePlan.rateType">
                            <s:iterator value="@com.derbysoft.remote.dswitch.hotel.constants.RateType@values()"
                                        id="rateType">
                                <option value="${rateType}">${rateType}</option>
                            </s:iterator>
                        </select>
                    </td>
                </tr>
                <tr>
                    <td class="key">PaymentType:</td>
                    <td class="value">
                        <select class="select" name="ratePlan.paymentType">
                            <s:iterator value="@com.derbysoft.remote.dswitch.hotel.constants.PaymentType@values()"
                                        id="paymentType">
                                <option value="${paymentType}">${paymentType}</option>
                            </s:iterator>
                        </select>
                    </td>
                </tr>
            </table>
        </fieldset>
        <input type="button" value="Create" class="common_button" onclick="create_rate_plan();"/>
        <input type="button" value="Back" class="common_button"
               onclick="window.location.href='./queryRatePlans.dhtml'"/>
    </form>
</div>

</body>
</html>